<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <title>Insert title here</title>
  <script>
    var selectFile;
    function upload(event) {
      console.log("xxxxxxxxxxx");
      console.log(event);
      var files = event.target.files;
      selectFile = files.item(0);
    }
    function sub() {

      if (selectFile == null) {
        alert("未选中文件");
        return;
      }

      var formData = new FormData();
      formData.append('fileName',selectFile);
      let config = {
        headers: {
          'Content-Type': 'multipart/form-data',
        }
      };

      axios
        .post('http://localhost:8080/fileUpload', formData, config);
        /*.then((response) => {
          console.log(response);
        });*/
    }
  </script>
  <script src="https://unpkg.com/axios/dist/axios.min.js">
  </script>
</head>
<body>
<h1>文件上传</h1>
<form >
  <p>选择文件: <input type="file" name="fileName" onchange="upload(event)"/></p>
  <p><input type="button" value="提交" onclick="sub()"/></p>
</form>
</body>
</html>

